<template>
	<view class="page">
		<view class="page-content">
			<view class="credit-box" v-if="formData.id!=''">
				<view class="u-flex u-row-between">
					<view class="credit-score">
						<text>{{formData.localCreditScore}}</text>
						<view>地方征信得分</view>
					</view>
					<view class="credit-right">
						<view><label>贷款金融机构数</label><text>{{formData.loanFinancialInstitutionsCount}}次</text></view>
						<view><label>半年内审批查询次数</label><text>{{formData.inquiriesInLastSixMonths}}次</text></view>
						<view><label>利息逾期次数</label><text>{{formData.interestOverdueCount}}次</text></view>
					</view>
				</view>
				<view class="credit-other">
					{{formData.otherInterests}}
				</view>
				<JSGJImages :imagesList="attachmentList"></JSGJImages>
			</view>
			<view v-else class="no-data-text">
				<view class="explain uni-center">
					暂无征信信息
				</view>
			</view>
			<files-list :customerId="customerId" title="企业人行征信附件" type="qiyerenhangzhengxin"></files-list>
		</view>
		<u-gap height="20" bg-color="#f0f2f6"></u-gap>
		<!-- 企业借款 -->
		<business-borrowings :customerId="customerId" :refreshKey="refreshKey"></business-borrowings>
		<!-- 重大关系人人行征信 -->
		<party-credit :customerId="customerId" :refreshKey="refreshKey"></party-credit>
		<!-- 重大关系人借款 -->
		<party-borrowings :customerId="customerId" :refreshKey="refreshKey"></party-borrowings>

		<view class="save-bottom" v-if="showBtn">
			<view class="fixed-btn save-padding">
				<u-button type="primary" shape="circle"
					@click="$helper.onJump(`/pagesJiushi/customer/creditDebt/creditDebt?id=${formData.id}&cid=${customerId}`)">{{formData.id?'编辑':'新增'}}征信信息</u-button>
			</view>
		</view>
	</view>
</template>

<script>
	import config from '@/common/js/config.js';
	import businessBorrowings from './businessBorrowings.vue';
	import partyCredit from './partyCredit.vue';
	import partyBorrowings from './partyBorrowings.vue';
	import filesList from '@/pagesJiushi/customer/actualController/components/filesList.vue'
	export default {
		components: {
			businessBorrowings,
			partyCredit,
			partyBorrowings,
			filesList
		},
		name: 'creditDebt',
		props: {
			customerId: {
				type: [Number, String],
				default () {
					return ''
				}
			}
		},
		created() {
			this.showBtn = uni.getStorageSync(config.Global.cache + '_ShowCompanyButton')
		},
		data() {
			return {
				showBtn: false,
				refreshKey: 1,
				formData: {
					id: '',
					loanFinancialInstitutionsCount: undefined,
					inquiriesInLastSixMonths: undefined,
					interestOverdueCount: undefined,
					otherInterests: undefined,
				},
				attachmentList: []
			};
		},
		watch: {
			customerId: {
				immediate: true,
				deep: true,
				handler(val) {
					this.getFormData()
				}
			}
		},
		methods: {
			getFormData() {
				this.$helper.ajax({
					url: "/api/Jiushi/Customercreditreport?customerId=" + this.customerId,
					method: "GET",
					contentType: "application/json",
					success: res => {
						if (res.data.data.list.length > 0) {
							this.formData = res.data.data.list[0]
							this.attachmentList = this.formData.attachmentInfo == null ? [] : this.formData
								.attachmentInfo.split(',')
						}
					}
				});
			},
		},
	}
</script>

<style lang="scss" scoped>
	.credit-box {
		background: #fff;
		padding: 24rpx;

		.credit-score {
			display: flex;
			flex-direction: column;
			width: 280rpx;
			align-items: center;
			background: #e9fbff;
			border-radius: 10rpx;
			padding: 16rpx 24rpx;

			text {
				font-size: 64rpx;
				font-weight: 500;
				line-height: 1;
				margin-bottom: 10rpx;
				color: #0077ff;
			}

			view {
				font-size: 24rpx;
				color: #999;
			}
		}

		.credit-right {
			flex: 1;

			>view {
				display: flex;
				flex-direction: row;
				align-items: center;
				justify-content: flex-end;

				label {
					color: #999;
					font-size: 24rpx;
				}

				text {
					padding-left: 10rpx;
					color: #f00;
					font-size: 28rpx;
				}
			}

		}

		.credit-other {
			margin-top: 20rpx;
			background: #f7f7f7;
			padding: 10rpx;
			border-radius: 8rpx;
			font-size: 24rpx;
		}
	}
</style>